package com.tangyuan.common.util;


import io.lettuce.core.dynamic.annotation.Command;
import io.lettuce.core.dynamic.annotation.CommandNaming;
import org.springframework.stereotype.Component;

@Component
public class NameConverter {

    /**
     *
     * @param name is_delete
     * @return isDelete
     */
    public static String convertToCamelCase(String name) {
        if (name == null || name.isEmpty()) {
            return name;
        }
        StringBuilder result = new StringBuilder();
        boolean nextIsUpperCase = false;

        for (char c : name.toCharArray()) {
            if (c == '_') {
                nextIsUpperCase = true;
            } else {
                if (nextIsUpperCase) {
                    result.append(Character.toUpperCase(c));
                    nextIsUpperCase = false;
                } else {
                    result.append(c);
                }
            }
        }
        return result.toString();
    }

}
